'use strict';

angular.module('homepageApp')
  .controller('ContactCtrl', function ($scope, Backendservice) {
        // function to submit the form after all validation has occurred
        $scope.submitForm = function(isValid) {

            // check to make sure the form is completely valid
            if (isValid) {
                var $data = JSON.stringify({email:$scope.user.email, subject:$scope.user.subject, message:$scope.user.message, name:$scope.user.name});
                Backendservice.postContactMessage($data).then(function(response){
                    //$scope.posts = response.data;
                });
                //$http.post('index.php/messages', $data).success(successCallback);
                alert('We have recieved your message and will get back to you as soon as possible.');
                window.location.href="#";
            }
        };
  });
